@extends('admin/index')
@section('name')
    <h1><span class="label label-default"> 广告管理  </span></h1>
    <hr>

    <table class="table table-bordered  table-hover" id="tent">
        <tr>
            <th>ID</th>
            <th>图片</th>
            <th>链接</th>
            <th>操作</th>
        </tr>
        @foreach($result as $v)
        <tr>
            <td>{{$v->id}}</td>
            <td><img src="{{url($v->img)}}" width="50px"></td>
            <td>{{$v->link}}</td>
            <td>
                <a href="{{url('/logo/upd')}}/{{$v->id}}" class="btn btn-info">修改</a>
                <button class="btn btn-danger" id="but1" onclick="del({{$v->id}})">删除</button>
            </td>
        </tr>
        @endforeach
    </table>
    {{$result->links()}}
    <script>
        function del($id) {
            var id = $id;

            $.ajax({
                type: 'get',
                url: "{{url('/logo/del')}}/" + id,
                data: id, //发送请求数据
                success: function (data) {
                    console.log(data);
                    if (data == 1) {
                        $("table#tent tr").click(function () {
                            $(this).remove();
                        });
                        window.location.href='{{url('/adm/logo')}}';
                    } else {
                        alert('删除失败');
                    }
                },
                error:function () {
                    alert('ajax请求失败');
                }
            });
        }
    </script>

@endsection
